package nextoffer.Tencent1;

import java.util.*;

public class dier {
    public static void main(String[] args) {
//        System.out.println(5^1);
        int n,k;
        Scanner in = new Scanner(System.in);
         n = in.nextInt();
         k = in.nextInt();
         int [] arr = new int[n];
         for(int i = 0; i < n;i++){
             arr[i] = in.nextInt();
         }
         int[][] x = new int[n][2];
        for(int i = 0 ;i < n;i++){
            x[i][0] = arr[i];
            x[i][1] = check(arr[i]);
        }
        Arrays.sort(x, (a,b) -> a[1] - b[1]);
        for(int i = 0 ; i < n; i++) {
            if(k < 0)break;
            if(k >= x[i][1]){
                k-=x[i][1];
                x[i][0] = 0;
            } else {
                ArrayList<Integer> list = new ArrayList<>();
                while(x[i][0] > 0) {
                    if((x[i][0] & 1) == 1 ){
                        list.add(1);
                    } else {
                        list.add(0);
                    }
                    x[i][0] >>= 1;
                }
                for(int j = 0 ; j < list.size();j++) {
                    if(list.get(j) == 1 && k > 0){
                        list.set(j, 0);
                        k--;
                    }
                }
                int sum = 0;

                for(int j = 0 ; j < list.size();j++) {
                    if(list.get(j) == 1)
                    sum += Math.pow(2,j);
                }
                x[i][0] = sum;


            }
        }
        int res = 0;
        for(int i = 0 ; i < n; i++) {
            res+=x[i][0];
        }
        System.out.println(res);
    }
    private  static  int check(int x){
        int cnt = 0;
        while(x > 0) {
            if((x & 1) == 1) {
                cnt++;
            }
             x>>= 1;
        }
        return cnt;
    }
}
